//
//  LGConsultRecordSurgeryCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/20.
//

#import "LGConsultRecordSurgeryCell.h"

@interface LGConsultRecordSurgeryCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UIImageView *patientTip;
/**   */
@property (nonatomic , strong)UILabel *surgeryLabel;
/**   */
@property (nonatomic , strong)UILabel *zhijiaLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;

@end

@implementation LGConsultRecordSurgeryCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setContent:(NSString *)content{
    _content = content;
    self.dateLabel.text = content;
}

//-(void)setDataDic:(NSDictionary *)dataDic{
//    _dataDic = dataDic;
//    self.dateLabel.text = LGNSString(dataDic[@"date"]);
//    self.surgeryLabel.text = LGNSString(dataDic[@"short_names"]);
//    NSArray *itemArray = dataDic[@"zhijia"];
//    NSString *zhijia = @"";
//    for (NSInteger i=0; i<itemArray.count; i++) {
//        NSDictionary *tempDic = itemArray[i];
//        zhijia = (zhijia.length>0)?[NSString stringWithFormat:@"%@ %@*%@",zhijia,tempDic[@"name"],tempDic[@"number"]]:[NSString stringWithFormat:@"支架：%@*%@",tempDic[@"name"],tempDic[@"number"]];
//    }
//    self.zhijiaLabel.text = zhijia;
//    NSString *ispatient = LGNSString(dataDic[@"is_patient"]);
//    self.patientTip.hidden = [ispatient isEqualToString:@"Y"]?NO:YES;
//    self.tipView.hidden = [ispatient isEqualToString:@"Y"]?YES:NO;
//}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.patientTip];
    [self.contentView addSubview:self.tipView];
    [self.contentView addSubview:self.surgeryLabel];
    [self.contentView addSubview:self.zhijiaLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.equalTo(self.contentView).offset(-viewPix(16));
        make.left.bottom.equalTo(self.contentView).offset(viewPix(16));
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(10));
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.top.equalTo(self.contentView).offset(viewPix(2));
    }];
    [self.patientTip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.dateLabel);
        make.width.equalTo(@(viewPix(46)));
        make.height.equalTo(@(viewPix(16)));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.width.height.equalTo(@(viewPix(12)));
        make.centerY.equalTo(self.dateLabel);
    }];
    [self.surgeryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel);
        make.right.equalTo(self.tipView);
        make.top.equalTo(self.dateLabel.mas_bottom).offset(viewPix(0));
    }];
    [self.zhijiaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.surgeryLabel.mas_bottom).offset(viewPix(0));
        make.left.right.equalTo(self.surgeryLabel);
        make.bottom.equalTo(self.contentView).offset(-viewPix(5));
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _dateLabel;
}

-(UIImageView *)patientTip{
    if(!_patientTip){
        _patientTip = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"手术记录-患者自填"]];
        _patientTip.hidden = YES;
    }
    return _patientTip;
}

-(UILabel *)surgeryLabel{
    if(!_surgeryLabel){
        _surgeryLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _surgeryLabel;
}

-(UILabel *)zhijiaLabel{
    if(!_zhijiaLabel){
        _zhijiaLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _zhijiaLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip12"]];
        _tipView.hidden = YES;
    }
    return _tipView;
}

@end
